package com.dsc.resolver;

import org.springframework.cloud.gateway.filter.ratelimit.KeyResolver;
import org.springframework.http.server.reactive.ServerHttpRequest;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;

public class GetWayResolver implements KeyResolver {
    @Override
    public Mono<String> resolve(ServerWebExchange exchange) {
        return Mono.just(buiderKey(exchange));
    }

    private String buiderKey(ServerWebExchange exchange){
        ServerHttpRequest request = exchange.getRequest();
        String path = request.getURI().getPath();
        String hostaddress = request.getRemoteAddress().getAddress().getHostAddress();
        return path.concat(".").concat(hostaddress);
    }
}
